package com.ericsson.enap.modules.replay.service.impl;

import com.ericsson.enap.modules.replay.entity.EpcReplayProjectFnumber;
import com.ericsson.enap.modules.replay.mapper.EpcReplayProjectFnumberMapper;
import com.ericsson.enap.modules.replay.service.IEpcReplayProjectFnumberService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 测试项目流程图Service业务层处理
 *
 * @author wangjingshi
 * @date 2020-09-13
 */
@Service
public class EpcReplayProjectFnumberServiceImpl implements IEpcReplayProjectFnumberService
{
    @Resource
    private EpcReplayProjectFnumberMapper epcReplayProjectFnumberMapper;


    /**
     * 查询测试项目流程图
     *
     * @param id 测试项目流程图ID
     * @return 测试项目流程图
     */
    @Override
    public EpcReplayProjectFnumber selectEpcReplayProjectFnumberById(String id)
    {
        return epcReplayProjectFnumberMapper.selectEpcReplayProjectFnumberById(id);
    }

    @Override
    public List<EpcReplayProjectFnumber> selectEpcReplayProjectFnumberByProjectId(String projectId) {
        return epcReplayProjectFnumberMapper.selectEpcReplayProjectFnumberByProjectId(projectId);
    }

    /**
     * 查询测试项目流程图列表
     *
     * @param epcReplayProjectFnumber 测试项目流程图
     * @return 测试项目流程图
     */
    @Override
    public List<EpcReplayProjectFnumber> selectEpcReplayProjectFnumberList(EpcReplayProjectFnumber epcReplayProjectFnumber)
    {
        return epcReplayProjectFnumberMapper.selectEpcReplayProjectFnumberList(epcReplayProjectFnumber);
    }


    private void selectChildrenId(EpcReplayProjectFnumber fnumber, List<String> ids) {
        ids.add(fnumber.getId());
        EpcReplayProjectFnumber erpf = new EpcReplayProjectFnumber();
        erpf.setPid(fnumber.getId());
        List<EpcReplayProjectFnumber> list = epcReplayProjectFnumberMapper.selectEpcReplayProjectFnumberList(erpf);
        if(list.size() > 0) {
            for(EpcReplayProjectFnumber l : list) {
                selectChildrenId(l,ids);
            }
        }
    }


}
